def ugly_number(num):
    if num <= 0:
        return False
    factors = [2, 3, 5]

    for f in factors:
        while num % f == 0:
            num = num // f

    return num == 1

print(ugly_number(6))
print(ugly_number(8))
print(ugly_number(14))